﻿Imports System.Data

Public Class ClerkManage_Page
    Public Sub Initialize()
        TextBoxClerkId.Text = ""
        TextBoxClerkName.Text = ""
        RadioButtonMale.IsChecked = True
        RadioButtonUnMarried.IsChecked = True
        TextBoxPhone.Text = ""
        TextBoxAddress.Text = ""
        TextBoxMoney.Text = ""
        TextBoxDay.Text = ""
        ComboBoxZhiWei.SelectedIndex = 0
    End Sub

    Private Sub ButtonSearch_Click(sender As System.Object, e As System.Windows.RoutedEventArgs) Handles ButtonSearch.Click
        Try
            Dim Level As Long
            Dim DS As DataSet = ClerkManage.clerkmanange(TextBoxClerkId.Text, Level)
            Dim DT As DataTable = DS.Tables("ClerkInfo1")
            TextBoxClerkName.Text = DT.Rows(0)("姓名").ToString
            If Convert.ToInt32(DT.Rows(0)("性别")) Then
                RadioButtonMale.IsChecked = True
            Else
                RadioButtonFamale.IsChecked = True
            End If
            If Convert.ToBoolean(DT.Rows(0)("婚否")) Then
                RadioButtonMarried.IsChecked = True
            Else
                RadioButtonUnMarried.IsChecked = True
            End If
            TextBoxPhone.Text = DT.Rows(0)("电话").ToString
            TextBoxAddress.Text = DT.Rows(0)("住址").ToString
            TextBoxMoney.Text = DT.Rows(0)("薪金").ToString
            TextBoxDay.Text = DT.Rows(0)("聘用日期").ToString
            ComboBoxZhiWei.SelectedIndex = Level
        Catch err As Exception
            MsgBox(err.Message)
        End Try
    End Sub

    Private Sub ButtonSubmit_Click(sender As System.Object, e As System.Windows.RoutedEventArgs) Handles ButtonSubmit.Click
        Try
            ClerkManage.clerkmanange(TextBoxClerkId.Text, _
                                    TextBoxClerkName.Text, _
                                    RadioButtonMale.IsChecked, _
                                    RadioButtonMarried.IsChecked, _
                                    TextBoxPhone.Text, _
                                    TextBoxAddress.Text, _
                                    ComboBoxZhiWei.SelectedIndex, _
                                    Convert.ToInt32(TextBoxMoney.Text))
            MsgBox("修改成功")
        Catch err As Exception
            MsgBox(err.Message)
        End Try
    End Sub

    Private Sub ClerkManage_Page_KeyDown(sender As Object, e As System.Windows.Input.KeyEventArgs) Handles Me.KeyDown
        If e.Key = Key.Return Then ButtonSubmit_Click(sender, New RoutedEventArgs)
    End Sub
End Class
